package de.ubschmidt.capi;

/**
 * Definition of the bits contained in an InfoMask.
 */
public enum InfoMaskBit {
    /**
     * Cause information given by the network during disconnection. The
     * info element parameter of the corresponding INFO_IND message is
     * a COMMON-ISDN-API struct which contains the cause information
     * element as defined in ETS 300 102-1 and Q.931 (4.5.12 in both).
     */
    CAUSE(0),

    /**
     * Date/time information indicated by the network. The info element
     * parameter of the corresponding INFO_IND message contains the date/time
     * information element as defined in ETS 300 102-1 and Q.931 (4.6.1 in
     * both).
     */
    DATE_TIME(1),

    /**
     * Information to be displayed to the user. The info element parameter
     * of the corresponding INFO_IND message contains the display information
     * element as defined in ETS 300 102-1 and Q.931 (4.5.15 in both).
     */
    DISPLAY(2),

    /**
     * User-user information that is carried transparently by the network.
     * The info element parameter of the corresponding INFO_IND message
     * contains the user-user information element as defined in ETS 300 102-1
     * and Q.931 (4.5.29 in both).
     */
    USER_USER(3),

    /**
     * Call progress: information regarding to the progress of the call.
     * There are five different INFO_IND messages that correspond to this
     * information type, each with a unique info number.
     * The first INFO_IND contains the progress indicator information element
     * as defined in ETS 300 102-1 and Q.931. The other four messages
     * indicate the occurrence of the network events SETUP ACKNOWLEDGE,
     * CALL PROCEEDING, ALERTING and PROGRESS. In these cases, the Info
     * number parameter indicates the event, and the Info element is an
     * empty COMMON-ISDN-API struct.
     */
    CALL_PROGRESS(4),

    /**
     * Facility information to indicate the invocation and operation
     * of supplementary services. The Info element parameter of the
     * corresponding INFO_IND message contains the facility information
     * element as defined in ETS 300 102-1 and Q.931 (4.6.2 in both).
     */
    FACILITY(5),

    /**
     * connection-oriented charge information provided by the network.
     * There are two different INFO_IND messages, with unique Info number
     * values, that correspond to this information type. The first shows
     * the total charge units indicated by the network up to this moment;
     * the second shows the total charges in the national currency indicated
     * by the network up to this moment. In both cases, the Info element
     * parameter is coded as a COMMON-ISDN-API struct containing a dword.
     * It is highly recommended that only one of these two types of charge
     * information be supplied to the user, and that the application convert
     * one type to the other. However, in some networks this might be
     * impossible due to ambiguous information provided by the network. In
     * such cases it is not defined whether the current charges are represented
     * by only one or by both types of information, or by the sum of the two.
     */
    CHARGE_INFORMATION(6),

    /**
     * Identifies the destination of a call. The info element parameter
     * of the corresponding INFO_IND message contains the called party
     * number information element as defined in ETS 300 102-1 and Q.931
     * (4.5.8 in both).
     */
    CALLED_PARTY_NUMBER(7),

    /**
     * Identifies the used channel of a call. The info element parameter
     * of the corresponding INFO_IND message contains the channel
     * identification information element as defined in ETS 300 102-1 and
     * Q.931 (4.5.13 in both).
     */
    CHANNEL_IDENTIFICATION(8),

    /**
     * Enables "early B3 connect" (see note). When this bit is set to 1,
     * a B-channel connection (NCCI) may be established based on a D-channel
     * connection (PLCI) which has not yet been established. Additional
     * information regarding the progress of the call is sent to the
     * application. There are two different INFO_IND messages that correspond
     * to this information type, each with a unique info number:
     * The first INFO_IND contains the progress indicator information element
     * as defined in ETS 300 102-1 and Q.931. The other indicates the
     * occurrence of the network event DISC. In this case, the Info number
     * parameter indicates the corresponding event and the Info element is
     * an empty COMMON-ISDN-API struct.
     */
    EARLY_B3_CONNECT(9),

    /**
     * Redirecting/redirection information indicated by the
     * network. The info element parameter of the corresponding INFO_IND
     * message contains the redirecting/redirection number information
     * element defined in ETS 300 207 (7.2).
     */
    REDIRECT_INFORMATION(10),

    /**
     * Indicates the completion of the called party number. The info
     * element parameter of the corresponding INFO_IND message contains
     * the sending complete information element as defined in ETS 300 102-1
     * and Q.931 (4.5.27 in both). The sending complete information element
     * may be sent by the network after completion of the called party number;
     * this can be helpful especially for the overlap receiving (direct dial
     * in, DDI) case, where the called party number may be spread over
     * multiple INFO_IND messages containing the called party number
     * information element (see bit 7).
     */
    SENDING_COMPLETE(12);

    /** The bit number. */
    private int _value;

    /**
     * Create a new {@code InfoMaskBit} which is represented by the specified
     * bit number.
     *
     * @param value The bit number.
     */
    InfoMaskBit(final int value) {
        _value = value;
    }

    /**
     * Retrieve the bit number of this enum.
     *
     * @return The bit number.
     */
    public int getValue() {
        return _value;
    }

    /** {@inheritDoc} */
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();

        sb.append(name());
        sb.append("(").append(getValue()).append(")");

        return sb.toString();
    }
}
